<template>
  <el-table :data="dataList" border fit highlight-current-row @selection-change="handleSelectionChange">
    <!-- <el-table-column type="selection" width="55">
    </el-table-column> -->
    <el-table-column v-for="(item) in engTh" :key="item" :label="formTh[`${item}`]">
      <template v-slot="scope">
        {{ handleItem(item, scope.row[`${item}`]) }}
      </template>
    </el-table-column>
  </el-table>
</template>
<script lang="ts" setup>
import { CostTransactionProcess } from "@/requests/request";
import { exportExcel, filterExcelContentArr } from "@/utils/excel";
import { engThInit, purTableHeader, purTableProps } from "./data";
import { onMounted } from "vue";

const props = defineProps({
  dataList: Array<CostTransactionProcess>,
  engTh: {
    type: Array<String | null>,
    default: () => engThInit
  },
});
const formTh = Object.assign({}, purTableHeader)
// const emit = defineEmits(['showJournalList'])
onMounted(() => {
  console.log('数据123', formTh, props.dataList)
})

let selectedArr: Array<any> = []
const handleSelectionChange = (val: Array<any>) => {
  console.log('选择的值', val);
  selectedArr = val;
}
const exportItems = () => {
  const sheetArr = filterExcelContentArr(selectedArr, purTableProps, purTableHeader)
  console.log('过滤的值', sheetArr)
  exportExcel("事务处理明细.xlsx", sheetArr)

}
// 暴露出去被引用
defineExpose({
  exportItems
})
enum accountingTypeEnum {
  "入库检验" = 1,
  "库存估价" = 2,
  "采购价格差异或汇率差异" = 3,
}
const handleItem = (key: any, value: any) => {
  if (key === 'accountingType') {
    return accountingTypeEnum[value]
  } else {
    return value
  }
}
</script>
